using AutoMapper;
using CoreManager.Models.DTOs;
using CoreManager.Models.Entities;

namespace CoreManager.Models.Mappings
{
    /// <summary>
    /// 角色映射配置
    /// </summary>
    public class RoleMappingProfile : Profile
    {
        public RoleMappingProfile()
        {
            // Role -> RoleDto
            CreateMap<Role, RoleDto>()
                .ForMember(dest => dest.MenuIds, opt => opt.Ignore())
                .ForMember(dest => dest.Menus, opt => opt.Ignore());

            // CreateRoleDto -> Role
            CreateMap<CreateRoleDto, Role>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore());

            // UpdateRoleDto -> Role
            CreateMap<UpdateRoleDto, Role>()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.CreateTime, opt => opt.Ignore())
                .ForMember(dest => dest.UpdateTime, opt => opt.Ignore());
        }
    }
}
